﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ArticleManager.Helpers
{
    class Logger
    {
        private string logFileName;
        public Logger()
        {
            logFileName=AppDomain.CurrentDomain.BaseDirectory + "\\" + "ErrorLog_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Year + ".log";
        }

        /// <summary>
        /// Pass in the fully qualified name of the log file you want to write to
        /// and the message to write
        /// </summary>
        /// <param name="LogPath"></param>
        /// <param name="Message"></param>
        public void WriteToLog(string Message)
        {
            try
            {
                using (StreamWriter s = File.AppendText(logFileName))
                {
                    s.WriteLine(DateTime.Now + "\t" + Message);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
    }
}
